class Solution:
    def exchange(self, nums: List[int]) -> List[int]:
        i, j = 0, len(nums)-1
        while i < j:
            if nums[i]%2:
                i += 1
            elif not nums[j]%2:
                j -= 1
            else:
                nums[i], nums[j] = nums[j], nums[i]
        return nums